var request = require('request')
var fs = require('fs')
var path = require('path');
var json = require("./index.js"); //数据
var log = console.log,max=json.length,now=0;
log(`-------------开始下载了--------------`);

function inImage(){
	if(now<max){
		log(`正在下载第${now}张。`);
		request(json[now].img).pipe(fs.createWriteStream(`./image/${json[now].alt}.jpg`));
		log(`第${now}张，下载完成。`);
		now++;		
		setTimeout(()=>{
			log(`开始第${now}张。`);
			inImage();
		},200)
	}else{
		log(`·············已全部下载················`)
	}
}
inImage();